import Vue from 'vue';
import VueRouter from 'vue-router';
// 自定义加载动画
import dialog from '../views/dialog';
// 底部tabbar
import tabBar from '../views/tabBar/tabBar.vue';
// 首页
import Home from '../views/home/home.vue';
// 逛市场
import merchant from '../views/merchant/index.vue';
import map from '../views/map/map.vue';
import yunying from '../views/map/yunying.vue';
// 个人中心
import mine from '../views/mine/index.vue';
// 圈子
import circle from '../views/circle/circle.vue';
// 搜索页面
import searchPage from '../views/merchant/searchPage.vue';
// 搜索后列表页面
import searchList from '../views/merchant/searchList.vue';
// 商店列表页面
import storePage from '../views/merchant/storePage.vue';
// 用户设置页面
import userSettings from '../views/mine/user/userSettings';
// 系统用户页面
import systemMessages from '../views/mine/user/systemMessages'
// 常见问题
import faq from '../views/mine/user/faq'
// 反馈
import feedback from '../views/mine/user/feedback'
// 反馈成功
import feedbackSuccess from '../views/mine/user/feedbackSuccess'
// 关于我们
import aboutUs from '../views/mine/user/aboutUs'
// 安全页面
import safety from '../views/mine/user/safety'
// 发布
import issue from '../views/mine/manage/issue'
// 新增发布
import addIssue from '../views/mine/manage/addIssue'
Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'tabBar',
    component: tabBar,
    children: [
      {
        path: '/',
        name: 'home',
        component: Home,
      },
      {
        path: '/merchant',
        name: 'merchant',
        component: merchant,
      },
      {
        path: '/circle',
        name: 'circle',
        component: circle,
      },
      {
        path: '/mine',
        name: 'mine',
        component: mine,
      },
    ]
  },
  // 搜索页面
  {
    path: '/searchPage',
    name: 'searchPage',
    component: searchPage,
  },
  // 搜索后的列表页
  {
    path: '/searchList',
    name: 'searchList',
    component: searchList,
  },
  // 商店页面
  {
    path: '/storePage',
    name: 'storePage',
    component: storePage,
  },
  // 用户设置页面
  {
    path: '/userSettings',
    name: 'userSettings',
    component: userSettings,
  },
  // 系统通知
  {
    path: '/systemMessages',
    name: 'systemMessages',
    component: systemMessages,
  },
  // 常见问题
  {
    path: '/faq',
    name: 'faq',
    component: faq,
  },
  //地图
  {
    path: '/map',
    name: 'map',
    component: map,
  },
  //运营中心
  {
    path: '/yunying',
    name: 'yunying',
    component: yunying,
  },
  // 反馈
  {
    path: '/feedback',
    name: 'feedback',
    component: feedback,
  },
  // 反馈成功
  {
    path: '/feedbackSuccess',
    name: 'feedbackSuccess',
    component: feedbackSuccess,
  },
  // 关于我们
  {
    path: '/aboutUs',
    name: 'aboutUs',
    component: aboutUs,
  },
  // 安全
  {
    path: '/safety',
    name: 'safety',
    component: safety,
  },
  // 发布
  {
    path: '/issue',
    name: 'issue',
    component: issue,
  },
  // 新增发布
  {
    path: '/addIssue',
    name: 'addIssue',
    component: addIssue,
  },
  // 动画页面
  {
    path: '/dialog',
    name: 'dialog',
    component: dialog,
  },
];

const router = new VueRouter({
  routes,
  // 返回 savedPosition，在按下 后退/前进 按钮时，就会像浏览器的原生表现那样：
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
});
export default router;
